<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return['basic']=$this->plugin_setting('basic');
$return['ischecklogin']=cfc('core')->checklogin('','',true);
$this->model('member')->upmember();
if($_RQ['op']=='main'){
	set_html('title','体质记录');
	$member=model('core/member')->detail($_SESSION['uid'],array('credit1','credit2','credit3','credit4','credit5','credit6','mobile','groupid','avatar','nickname'));
	if(!$member){
		//exi('找不到会员信息！','error');
	}
	$this->model('model')->checklogin();	
	$user=pdo_get('jy_aixiaoyi_member',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	//VIP时间：
	$user['vipstatus']=$user['viptime']>time()?1:2;
	$user['viptime']=date('Y/m/d',$user['viptime']);
	$member['avatar']=tomedia($member['avatar']);
	$return['member']=$member;
	$return['item']=array();
	exi($return);
}
if($_RQ['op']=='detail'){
	set_html('title','体质详情');
	$member=model('core/member')->detail($_SESSION['uid'],array('credit1','credit2','credit3','credit4','credit5','credit6','mobile','groupid','avatar','nickname'));
	$return['memberbasic']=$member;
	$item=pdo_get('jy_aixiaoyi_tilog',array('id'=>$_RQ['id'],'uniacid'=>$_SESSION['uniacid']));
	$item['content']=json_decode($item['content'],true);
	$syndrome=$item['content']['syndrome'];
	$item['jieguodesc']='';
	$item['tiaolidesc']='';
	foreach($syndrome as $k=>$sv){
		$num=$k+1;
		$item['jieguodesc'] .=$num.','.$sv['bingjigaiyao'].';';
		$item['tiaolidesc'] .=$num.','.$sv['zhizezhifa'].';';
		$item['yaodesc'] .=$num.','.$sv['fangjizucheng'].$sv['zhongyaofangji'].';';
	}
	if(!$item['jieguodesc'] && $item['content']['code']!='88' && $item['content']['code']!='8888'){
		$item['jieguodesc']=$item['content']['message']?:$item['content']['errMsg'];
		$item['tiaolidesc']='错误码：'.$item['content']['code'];
	}
	$char=$item['content']['char'];
	$item['shexing']='';
	$item['taixing']='';
	$xingnum=0;
	$tainum=0;
	foreach($char as $k=>$sv){
		if($k==2 || $k==3 || $k==4|| $k==6){
			$xingnum++;
			$item['shexing'] .=$xingnum.','.$sv['type'].';';
		}
		if($k==0 || $k==1 || $k==5|| $k==7|| $k==9){
			$tainum++;
			$item['taixing'] .=$tainum.','.$sv['type'].';';
		}
	}
	$item['shese']=$char[8]['type'];
	$item['taise']=$char[0]['type'];
	$tiaoli=$item['content']['tiaoli'];
	$item['tiaolidesc2']='';
	foreach($tiaoli as $k=>$sv){
		if($k!='shiliao'){
			$item['tiaolidesc2'] .=$num.','.$sv.';';
		}
	}
	$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
	$item['probability']=round($item['content']['picQuality']['probability'],4);
	$return['item']=$item;
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid']);
	$params['mid']=$_SESSION['uid'];
	$_RQ['page'] = $_RQ['page'] ? $_RQ['page'] : 1;
	$pindex = max(1, intval($_RQ['page']));
	if(intval($_RQ['num'])){
		$psize = intval($_RQ['num']);
	}else{
		$psize = 10;
	}
	$total='';
	$list=pdo_getslice('jy_aixiaoyi_tilog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['content']=json_decode($item['content'],true);
			$syndrome=$item['content']['syndrome'];
			$item['jieguodesc']='';
			$item['tiaolidesc']='';
			foreach($syndrome as $k=>$sv){
				$num=$k+1;
				$item['jieguodesc'] .=$num.','.$sv['bingjigaiyao'].';';
				$item['tiaolidesc'] .=$num.','.$sv['zhizezhifa'].';';
			}
			$item['probability']=round($item['content']['picQuality']['probability'],4);
			$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
			if(!$item['jieguodesc'] && $item['content']['code']!='88' && $item['content']['code']!='8888'){
				$item['jieguodesc']=$item['content']['message']?:$item['content']['errMsg'];
				$item['tiaolidesc']='错误码：'.$item['content']['code'];
			}
		}
	}
	$return['list']=$list;
	exi($return);
}